$(function(){	
	taskCancel('#taskCancelForm');
});

function taskCancel(obj){
	var $obj = $(obj);
	var $submit = $obj.find('input[type=submit]');
	var $load = $obj.find('.loading').hide();
	$obj.submit(function(){
		$load.show();
		$submit.attr('disabled',true);
		var $post = $.post($obj.attr('action'),{'message':$('#message').val()},function(data){
			if( data.status == 'ok'){
				$load.hide();
				alert(data.msg);
				window.parent.location.reload();				
			}else{
				alert(data.msg);
			}
			$submit.attr('disabled',true);
		},'json');
		setTimeout(function(){ $post.abort(); alert('已经退回,邮件发送失败:'); window.parent.location.reload();},20 * 1000);
		return false;
	});

}